package com.walker.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @ProjectName: walker-step
 * @Package: com.walker.web.controller
 * @ClassName: IndexController
 * @Author: yangyl
 * @CreateDate: 2020/7/26 21:36
 */
@Controller
public class IndexController {

    @RequestMapping("/index")
    @ResponseBody
    public Map<String,Object> index(){
        Map<String,Object> data=new HashMap<>(2);
        data.put("data","成功");
        return data;
    }

    @RequestMapping("getUsers")
    @ResponseBody
    public Map<String,Object> getUsers(Integer page,Integer limit){
        Map<String,Object> data=new HashMap<>(2);
        List<Map<String,Object>> rows=new ArrayList();
        for (int i = 1; i <= 100; i++) {
            Map<String,Object> d1=new HashMap<>();
            d1.put("id",i);
            d1.put("username","张三"+i);
            d1.put("city","北京"+i);
            rows.add(d1);
        }
        data.put("data",rows.subList((page-1)*limit,page*limit));
        data.put("code",0);
        data.put("count",rows.size());
        return data;
    }
}
